package com.saret.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * User: biniam.gebremichael
 * Date: Jul 16, 2010
 */
public class GeezUtil {

    public static Map<Integer, String> map = new HashMap<Integer, String>();

    public static boolean isGeez(String s) {
        return (s.length() > 0 && (s.charAt(0) > 4000 || s.equals(" ") || s.equals("\t") || s.equals("-") || s.equals(":")));
    }

    public static String cleanGeez(String vs) {
        if (vs == null || vs.length() < 2) {
            return "";
        }

        StringBuilder builder = new StringBuilder();
        for (String s : vs.split("")) {
            if (s.length() > 0 && ((s.charAt(0) < 4955 && s.charAt(0) > 4607) || s.matches("\\s"))) {
                builder.append(s);
            }
        }
        return builder.toString().trim();
    }

    public static String toLatin(String vs) {
        if (vs == null || vs.length() < 1) {
            return "";
        }

        StringBuilder builder = new StringBuilder();
        for (char s : vs.toCharArray()) {
            builder.append(toLatin((int) s));
        }
        return builder.toString().trim();
    }

    public static String toLatin(Integer i) {
        return map.get(i);
    }

    static {
        map.put(4608, "he");
        map.put(4609, "hu");
        map.put(4610, "hi");
        map.put(4611, "ha");
        map.put(4612, "hE");
        map.put(4613, "h");
        map.put(4614, "ho");
        map.put(4616, "le");
        map.put(4617, "lu");
        map.put(4618, "li");
        map.put(4619, "la");
        map.put(4620, "lE");
        map.put(4621, "l");
        map.put(4622, "lo");
        map.put(4623, "LWa");
        map.put(4624, "He");
        map.put(4625, "Hu");
        map.put(4626, "Hi");
        map.put(4627, "Ha");
        map.put(4628, "HE");
        map.put(4629, "H");
        map.put(4630, "Ho");
        map.put(4631, "HWa");
        map.put(4632, "me");
        map.put(4633, "mu");
        map.put(4634, "mi");
        map.put(4635, "ma");
        map.put(4636, "mE");
        map.put(4637, "m");
        map.put(4638, "mo");
        map.put(4639, "mWa");
        map.put(4640, "\'se");
        map.put(4641, "\'su");
        map.put(4642, "\'si");
        map.put(4643, "\'sa");
        map.put(4644, "\'sE");
        map.put(4645, "\'s");
        map.put(4646, "\'so");
        map.put(4647, "\'sWa");
        map.put(4648, "re");
        map.put(4649, "ru");
        map.put(4650, "ri");
        map.put(4651, "ra");
        map.put(4652, "rE");
        map.put(4653, "r");
        map.put(4654, "ro");
        map.put(4655, "rWa");
        map.put(4656, "se");
        map.put(4657, "su");
        map.put(4658, "si");
        map.put(4659, "sa");
        map.put(4660, "sE");
        map.put(4661, "s");
        map.put(4662, "so");
        map.put(4663, "sWa");
        map.put(4664, "Se");
        map.put(4665, "Su");
        map.put(4666, "Si");
        map.put(4667, "Sa");
        map.put(4668, "SE");
        map.put(4669, "S");
        map.put(4670, "So");
        map.put(4671, "SWa");
        map.put(4672, "qe");
        map.put(4673, "qu");
        map.put(4674, "qi");
        map.put(4675, "qa");
        map.put(4676, "qE");
        map.put(4677, "q");
        map.put(4678, "qo");
        map.put(4680, "qWe");
        map.put(4682, "qWi");
        map.put(4683, "qWA");
        map.put(4684, "qWa");
        map.put(4685, "qu");
        map.put(4688, "Qe");
        map.put(4689, "Qu");
        map.put(4690, "Qi");
        map.put(4691, "Qa");
        map.put(4692, "QE");
        map.put(4693, "Q");
        map.put(4694, "Qo");
        map.put(4696, "QWe");
        map.put(4698, "QWi");
        map.put(4699, "QWA");
        map.put(4700, "QWa");
        map.put(4701, "QWu");
        map.put(4704, "be");
        map.put(4705, "bu");
        map.put(4706, "bi");
        map.put(4707, "ba");
        map.put(4708, "bE");
        map.put(4709, "b");
        map.put(4710, "bo");
        map.put(4711, "bWa");
        map.put(4712, "ve");
        map.put(4713, "vu");
        map.put(4714, "vi");
        map.put(4715, "va");
        map.put(4716, "vE");
        map.put(4717, "v");
        map.put(4718, "vo");
        map.put(4719, "vWa");
        map.put(4720, "te");
        map.put(4721, "tu");
        map.put(4722, "ti");
        map.put(4723, "ta");
        map.put(4724, "tE");
        map.put(4725, "t");
        map.put(4726, "to");
        map.put(4727, "tWa");
        map.put(4728, "ce");
        map.put(4729, "cu");
        map.put(4730, "ci");
        map.put(4731, "ca");
        map.put(4732, "cE");
        map.put(4733, "c");
        map.put(4734, "co");
        map.put(4735, "cWa");
        map.put(4736, "_he");
        map.put(4737, "_hu");
        map.put(4738, "_hi");
        map.put(4739, "_ha");
        map.put(4740, "_hE");
        map.put(4741, "_h");
        map.put(4742, "_ho");
        map.put(4744, "_hWe");
        map.put(4746, "_hWi");
        map.put(4747, "_hWA");
        map.put(4748, "_hWE");
        map.put(4749, "_hu");
        map.put(4752, "ne");
        map.put(4753, "nu");
        map.put(4754, "ni");
        map.put(4755, "na");
        map.put(4756, "nE");
        map.put(4757, "n");
        map.put(4758, "no");
        map.put(4759, "nWa");
        map.put(4760, "Ne");
        map.put(4761, "Nu");
        map.put(4762, "Ni");
        map.put(4763, "Na");
        map.put(4764, "NE");
        map.put(4765, "N");
        map.put(4766, "No");
        map.put(4767, "NWa");
        map.put(4768, "\'e");
        map.put(4769, "\'u");
        map.put(4770, "\'i");
        map.put(4771, "\'a");
        map.put(4772, "\'E");
        map.put(4773, "\'I");
        map.put(4774, "\'o");
        map.put(4768, "e");
        map.put(4769, "u");
        map.put(4770, "i");
        map.put(4771, "a");
        map.put(4772, "E");
        map.put(4773, "I");
        map.put(4774, "o");
        map.put(4775, "Wa");
        map.put(4776, "ke");
        map.put(4777, "ku");
        map.put(4778, "ki");
        map.put(4779, "ka");
        map.put(4780, "kE");
        map.put(4781, "k");
        map.put(4782, "ko");
        map.put(4784, "kWa");
        map.put(4786, "kWi");
        map.put(4787, "kWa");
        map.put(4788, "kWa");
        map.put(4789, "ku");
        map.put(4792, "Ke");
        map.put(4793, "Ku");
        map.put(4794, "Ki");
        map.put(4795, "Ka");
        map.put(4796, "KE");
        map.put(4797, "K");
        map.put(4798, "Ko");
        map.put(4800, "KWa");
        map.put(4802, "KWi");
        map.put(4803, "KWa");
        map.put(4804, "KWa");
        map.put(4805, "Ku");
        map.put(4808, "we");
        map.put(4809, "wu");
        map.put(4810, "wi");
        map.put(4811, "wa");
        map.put(4812, "WE");
        map.put(4813, "w");
        map.put(4814, "wo");
        map.put(4816, "`e");
        map.put(4817, "`u");
        map.put(4818, "`i");
        map.put(4819, "`a");
        map.put(4820, "`E");
        map.put(4821, "`A");
        map.put(4822, "`o");
        map.put(4824, "ze");
        map.put(4825, "zu");
        map.put(4826, "zi");
        map.put(4827, "za");
        map.put(4828, "zE");
        map.put(4829, "z");
        map.put(4830, "zo");
        map.put(4831, "zWa");
        map.put(4832, "Ze");
        map.put(4833, "Zu");
        map.put(4834, "Zi");
        map.put(4835, "Za");
        map.put(4836, "ZE");
        map.put(4837, "Z");
        map.put(4838, "Zo");
        map.put(4839, "ZWa");
        map.put(4840, "ye");
        map.put(4841, "yu");
        map.put(4842, "yi");
        map.put(4843, "ya");
        map.put(4844, "yE");
        map.put(4845, "y");
        map.put(4846, "yo");
        map.put(4848, "de");
        map.put(4849, "du");
        map.put(4850, "di");
        map.put(4851, "da");
        map.put(4852, "dE");
        map.put(4853, "d");
        map.put(4854, "do");
        map.put(4855, "dWa");
        map.put(4856, "je");
        map.put(4857, "ju");
        map.put(4858, "ji");
        map.put(4859, "ja");
        map.put(4860, "jE");
        map.put(4861, "j");
        map.put(4862, "jo");
        map.put(4863, "jWa");
        map.put(4864, "Ge");
        map.put(4865, "Gu");
        map.put(4866, "Gi");
        map.put(4867, "Ga");
        map.put(4868, "GE");
        map.put(4869, "G");
        map.put(4870, "Go");
        map.put(4871, "GWa");
        map.put(4872, "ge");
        map.put(4873, "gu");
        map.put(4874, "gi");
        map.put(4875, "ga");
        map.put(4876, "gE");
        map.put(4877, "g");
        map.put(4878, "go");
        map.put(4880, "gWa");
        map.put(4882, "gWi");
        map.put(4883, "gWa");
        map.put(4884, "gWa");
        map.put(4885, "gu");
        map.put(4888, "Ge");
        map.put(4889, "Gu");
        map.put(4890, "Gi");
        map.put(4891, "Ga");
        map.put(4892, "GE");
        map.put(4893, "G");
        map.put(4894, "Go");
        map.put(4896, "Te");
        map.put(4897, "Tu");
        map.put(4898, "Ti");
        map.put(4899, "Ta");
        map.put(4900, "TE");
        map.put(4901, "T");
        map.put(4902, "To");
        map.put(4903, "TWa");
        map.put(4904, "Ce");
        map.put(4905, "Cu");
        map.put(4906, "Ci");
        map.put(4907, "Ca");
        map.put(4908, "CE");
        map.put(4909, "C");
        map.put(4910, "Co");
        map.put(4911, "CWa");
        map.put(4912, "Pa");
        map.put(4913, "Pu");
        map.put(4914, "Pi");
        map.put(4915, "Pa");
        map.put(4916, "PE");
        map.put(4917, "P");
        map.put(4918, "Po");
        map.put(4919, "PWa");
        map.put(4920, "xe");
        map.put(4921, "xu");
        map.put(4922, "xi");
        map.put(4923, "xa");
        map.put(4924, "xE");
        map.put(4925, "x");
        map.put(4926, "xo");
        map.put(4927, "xWa");
        map.put(4928, "Xe");
        map.put(4929, "Xu");
        map.put(4930, "Xi");
        map.put(4931, "Xa");
        map.put(4932, "XE");
        map.put(4933, "X");
        map.put(4934, "Xo");
        map.put(4936, "fe");
        map.put(4937, "fu");
        map.put(4938, "fi");
        map.put(4939, "fa");
        map.put(4940, "fE");
        map.put(4941, "f");
        map.put(4942, "fo");
        map.put(4943, "fWa");
        map.put(4944, "pe");
        map.put(4945, "pu");
        map.put(4946, "pi");
        map.put(4947, "pa");
        map.put(4948, "pE");
        map.put(4949, "p");
        map.put(4950, "po");
        map.put(4951, "pWa");
        map.put(4952, "pri");
        map.put(4953, "pma");
        map.put(4954, "pfi");
        map.put(32, " ");
    }
}

